const express = require("express");

const app = express();

app.use(express.static("./public"));

// API
// 中间件
// xhr.open('GET','http://127.0.0.1:3000/a/b')
app.get("/a/b", (req, res) => {
  res.send("hello get");
});
// xhr.open('POST','http://127.0.0.1:3000/a/b')
app.post("/a/b", (req, res) => {
  res.send("hello post");
});

// xhr.open('PUT','http://127.0.0.1:3000/a/b')
app.put("/a/b", (req, res) => {
  res.send("hello put");
});

// xhr.open('PATCH','http://127.0.0.1:3000/a/b')
app.patch("/a/b", (req, res) => {
  res.send("hello patch");
});

// xhr.open('DELETE','http://127.0.0.1:3000/a/b')
app.delete("/a/b", (req, res) => {
  res.send("hello delete");
});

app.listen(3000, () => {
  console.log("success", "http://127.0.0.1:3000");
});
